package Demo1;

import jakarta.servlet.annotation.WebServlet;

import java.lang.annotation.Annotation;

// 获取类上的注解信息
public class AnnotationForclass {
    public static void main(String[] args) throws Exception {
        Class<?> wel = Class.forName("Demo1.WelcomeServlet");
        // 判断是否有这个注解对象,若有这个对象就返回true
        boolean annotationPresent = wel.isAnnotationPresent(WebServlet.class);
        System.out.println(annotationPresent);
        if(annotationPresent){
            WebServlet webservletAnnotation = wel.getAnnotation(WebServlet.class);
            String[] s = webservletAnnotation.value();
            for (String a:s) {
                System.out.println(a);
            }
        }
    }
}
